const Router = require("koa-router");

const { verifyToken } = require("../middeleware/auth.middleware");
const {
  getRole,
  getRoles,
  addRole,
  deleteRole,
  editRole,
  getAllPowers,
  getAllPowersList,
  getRolelist,
  updatepermission,
} = require("../controller/roles.controller");

const roleRouter = new Router({ prefix: "/role" });

// 要放在 :id前面
roleRouter.get("/roles", verifyToken, getRoles);
roleRouter.get("/powers", verifyToken, getAllPowers);
// 查看 角色列表 添加角色时候来选择角色
roleRouter.get("/getroles", verifyToken, getRolelist);
roleRouter.get("/powerlist", verifyToken, getAllPowersList);

// 删除角色
roleRouter.get("/delete/:id", verifyToken, deleteRole);

roleRouter.get("/:id", verifyToken, getRole);

// 更新角色permission （删除）
roleRouter.post("/updatepermission", verifyToken, updatepermission);

// 编辑角色
roleRouter.post("/:id", verifyToken, editRole);

// 添加角色
roleRouter.post("/", verifyToken, addRole);

module.exports = roleRouter;
